<!-- Modal -->
<div class="modal-dialog wide" style="width: 550px;">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title" id="myModalLabel">编辑</h4>
        </div>
        <div class="modal-body">
            <div id="errorMessage"><#include "../../message.ftl" /></div>
            <form class="form-horizontal" role="form" id="keyGeneratorForm" method="post"
                  action="${absoluteContextPath}/system/keyGenerator/save">
            <#if keyGenerator??>
                <#if keyGenerator.id??>
                    <input type="hidden" name="id" value="${keyGenerator.id}"/>
                <#else>
                    <input type="hidden" name="id" value=""/>
                </#if>
            </#if>
                <div class="row">
                    <div class="form-group col-md-12">
                        <label class="col-sm-4 control-label">前缀</label>

                        <div class="col-sm-6">
                            <input name="prefix" value="${keyGenerator.prefix!''}" type="text" class="form-control"/>
                        </div>
                    </div>
                    <div class="form-group col-md-12">
                        <label class="col-sm-4 control-label">序号<sup style="color: red">*</sup></label>

                        <div class="col-sm-6">
                            <input name="num" value="${keyGenerator.num!''}" type="text" class="form-control"/>
                        </div>
                    </div>
                    <div class="form-group col-md-12">
                        <label class="col-sm-4 control-label">后缀</label>

                        <div class="col-sm-6">
                            <input name="suffix" value="${keyGenerator.suffix!''}" type="text" class="form-control"/>
                        </div>
                    </div>
                    <div class="form-group col-md-12">
                        <label class="col-sm-4 control-label">长度<sup style="color: red">*</sup></label>

                        <div class="col-sm-6">
                            <input name="length" value="${keyGenerator.length!''}" type="text" class="form-control"/>
                        </div>
                    </div>
                    <div class="form-group col-md-12">
                        <label class="col-sm-4 control-label">排序号</label>

                        <div class="col-sm-6">
                            <input name="sortNo" value="${keyGenerator.sortNo!''}" type="text" class="form-control"/>
                        </div>
                    </div>
                    <div class="form-group col-md-12">
                        <label class="col-sm-4 control-label">类型<sup style="color: red">*</sup></label>

                        <div class="col-sm-6">
                            <select name="type" class="form-control chosen-select">
                                <option value="">请选择...</option>
                            <#list keyTypeList as keyType>
                                <#if keyType.name() == keyGenerator.type!''>
                                    <option value="${keyType.name()}" selected>${keyType.getDesc()}</option>
                                <#else>
                                    <option value="${keyType.name()}">${keyType.getDesc()}</option>
                                </#if>
                            </#list>
                            </select>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</button>
            <button type="button" class="btn btn-primary" onclick="save();">保存</button>
        </div>
    </div>
</div>
<script>
    function save() {
        $("#" + "keyGeneratorForm").ajaxSubmit({
            success: function (data) {
                data = JSON.parse(data);
                if (data.returnCode == 1) {
                    $('#myModal').modal("hide");
                    $.showMessage({parentId: "showMessage", message: "信息保存成功！", type: "success"});
                    refreshTable();
                } else {
                    $.showMessage({parentId: "errorMessage", message: "<strong>错误信息</strong>：" + data.returnMsg, type: "success"});
                }
            }
        });
    }
</script>